Ext.define('Admin.view.page.group.project.Project', {
    extend: 'Ext.panel.Panel',
    requires: [
        'Admin.store.group.menu.MenuStore',
        'Admin.view.page.group.project.ProjectController',
        'Admin.view.page.group.project.ProjectModel',
        'Admin.model.group.menu.Menu',
    ],
    controller: 'group-project',
    viewModel: 'group-project',
    // id : 'group-menu-view',
    xtype: 'group-project-view',
    title: '项目组配置',
    frame: true,
    layout: {
        type: 'hbox',
        pack: 'start',
        align: 'stretch'
    },
    // rendered : true,
    // height: Ext.Element.getViewportHeight(),
    // bodyPadding: 10,
    // padding : '0 10 0 0',
    defaults: {
        frame: true,
        bodyPadding: 10
    },
    reference : 'groupMenuViewReference',
    initComponent: function(){

        let menuGridPanel = Ext.create('Ext.grid.Panel', 
        {
            
            title: '项目',
            reference: 'menuGridPanel',
            bind : {
                store : '{projectStore}',
            },
            plugins: {
                ptype: 'cellediting',
                clicksToEdit: 2
            },
            selModel: {
                // type: 'cellmodel',
                selType: 'rowmodel',
            },
            // height: 200,
            // width: 400,
            flex: 1,
            bbar: Ext.create('Ext.PagingToolbar', {
                // store: store,
                // pageSize: 20,
                bind : {
                    store : '{projectStore}',
                },
                displayInfo: true,
                displayMsg: '共{2}条,第 {0}到 {1}条',
                emptyMsg: "无记录",
                listeners: {
                    beforechange: 'menuGridPanelPagingToolbarBeforechange',
                }
            }),
            tbar: [{
                    xtype: 'textfield',
                    fieldLabel: '关键字',
                    labelWidth: 50,
                    // bind : {
                    //     value : '{menuGridKeyword}'
                    // }
                    bind: '{menuGridKeyword}'
                },'-',{ 
                    xtype: 'button',
                    text: '查询' ,
                    handler: 'queryMenuButton'
                },'->',{ 
                    xtype: 'button',
                    text: '添加' ,
                    handler: 'addMenuButton'
                },{ 
                    xtype: 'button',
                    text: '保存' ,
                    handler: 'saveMenuButton'
                },{ 
                    xtype: 'button',
                    text: '删除' ,
                    handler: 'deleteMenuProjectButton'
                },
            ],
            columns : [{
                    xtype: 'rownumberer'
                }, { 
                    header: '项目名称',
                    sortable: true,
                    dataIndex: 'name',
                    editor: {
                        xtype: 'textfield',
                        allowBlank: false
                    },
                    flex: 2
                },{
                    header: '排序',
                    sortable: true,
                    dataIndex: 'sort',
                    editor: {
                        xtype: 'numberfield',
                        allowBlank: false,
                        minValue: 0,
                        // maxValue: 100000
                    },
                    flex: 1
                },{
                    header: '组备注',
                    sortable: true,
                    dataIndex: 'remarks',
                    editor: {
                        xtype: 'textfield',
                        allowBlank: false
                    },
                    flex: 1
                }
            ],
            listeners: {
                //渲染完成后,加载数据
                afterrender: 'yeMenuGridAfterrender',
            }
        });

        Ext.apply(this,{
            items: [
                menuGridPanel,
            ]
        }
        )
        this.callParent();
    },
    listeners: {
        //渲染完成后,自定义宽高
        afterrender: 'yeAfterrender',
    }
});
